package com.weishu.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.weishu.common.log.annotation.Log;
import com.weishu.common.log.enums.BusinessType;
import com.weishu.common.security.annotation.PreAuthorize;
import com.weishu.system.domain.TJrSfLoanDetail;
import com.weishu.system.service.ITJrSfLoanDetailService;
import com.weishu.common.core.web.controller.BaseController;
import com.weishu.common.core.web.domain.AjaxResult;
import com.weishu.common.core.utils.poi.ExcelUtil;
import com.weishu.common.core.web.page.TableDataInfo;

/**
 * 收房贷申请明细Controller
 * 
 * @author weishu
 * @date 2021-10-19
 */
@RestController
@RequestMapping("/detail")
public class TJrSfLoanDetailController extends BaseController
{
    @Autowired
    private ITJrSfLoanDetailService tJrSfLoanDetailService;

    /**
     * 查询收房贷申请明细列表
     */
    @PreAuthorize(hasPermi = "core:detail:list")
    @GetMapping("/list")
    public TableDataInfo list(TJrSfLoanDetail tJrSfLoanDetail)
    {
        startPage();
        List<TJrSfLoanDetail> list = tJrSfLoanDetailService.selectTJrSfLoanDetailList(tJrSfLoanDetail);
        return getDataTable(list);
    }

    /**
     * 导出收房贷申请明细列表
     */
    @PreAuthorize(hasPermi = "core:detail:export")
    @Log(title = "收房贷申请明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TJrSfLoanDetail tJrSfLoanDetail) throws IOException
    {
        List<TJrSfLoanDetail> list = tJrSfLoanDetailService.selectTJrSfLoanDetailList(tJrSfLoanDetail);
        ExcelUtil<TJrSfLoanDetail> util = new ExcelUtil<TJrSfLoanDetail>(TJrSfLoanDetail.class);
        util.exportExcel(response, list, "detail");
    }

    /**
     * 获取收房贷申请明细详细信息
     */
    @PreAuthorize(hasPermi = "core:detail:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tJrSfLoanDetailService.selectTJrSfLoanDetailById(id));
    }

    /**
     * 新增收房贷申请明细
     */
    @PreAuthorize(hasPermi = "core:detail:add")
    @Log(title = "收房贷申请明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TJrSfLoanDetail tJrSfLoanDetail)
    {
        return toAjax(tJrSfLoanDetailService.insertTJrSfLoanDetail(tJrSfLoanDetail));
    }

    /**
     * 修改收房贷申请明细
     */
    @PreAuthorize(hasPermi = "core:detail:edit")
    @Log(title = "收房贷申请明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TJrSfLoanDetail tJrSfLoanDetail)
    {
        return toAjax(tJrSfLoanDetailService.updateTJrSfLoanDetail(tJrSfLoanDetail));
    }

    /**
     * 删除收房贷申请明细
     */
    @PreAuthorize(hasPermi = "core:detail:remove")
    @Log(title = "收房贷申请明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tJrSfLoanDetailService.deleteTJrSfLoanDetailByIds(ids));
    }
}
